<?php

namespace app\teacher\controller;

use app\admin\model\Admin;

class Article extends Base
{

    public $model = null;
    public function __construct(\app\admin\model\Article $model)
    {
        parent::__construct();
        $this->model = $model;
    }

    /**
     * 公告列表
     * @return void
     * @throws \think\exception\DbException
     */
    public function lists()
    {
        $this->success('success', $this->model->paginate());
    }

    /**
     * 公告详情
     * @return void
     * @throws \think\Exception
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function info()
    {
        $id = $this->request->get('id', 0);
        if (!$id) $this->error('参数错误');
        $info = $this->model->where('id', $id)->find();
        if (!$info) $this->error('数据不存在');
        $this->model->where('id', $id)->setInc('num');
        $this->success('success', $info);
    }
}